#pragma once
#include <iostream>
#include <pthread.h>

namespace ns_task
{
    class Task
    {
    public:
        Task()
        {}

        Task(int x, int y, char op)
            : _x(x), _y(y), _op(op)
        {
        }

        ~Task()
        {
        }

        int operator ()()
        {
            return Run();
        }
    public:
        int Run()
        {
            int ret = 0;
            switch(_op)
            {
                case '+':
                    ret = _x + _y;
                    break;
                case '-':
                    ret = _x - _y;
                    break;
                case '*':
                    ret = _x * _y;
                    break;
                case '/':
                    ret = _x / _y;
                    break;
                case '%':
                    ret = _x % _y;
                    break;
                default:
                    std::cout << "bug??" << std::endl;
                    break;
            }
            std::cout << "当线程是:" << pthread_self() << "正在执行" \
            << _x << _op << _y << "= " << ret << std::endl;
            return ret;
        }
    private:
        int _x;
        int _y;
        char _op;
    };
}
